package com.cn.ycy.exception;


import com.cn.ycy.entity.result.ResultCode;
import lombok.Getter;

/**
 * 内部code异常
 *
 * @author qiss
 */
public class RCException extends RuntimeException {

  private static final long serialVersionUID = 2359767895161832954L;

  @Getter
  private final ResultCode resultCode;

  /**
   * 异常信息
   */
  public RCException(String message) {
    super(message);
    this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
  }

  /**
   * Int类型异常编码,异常信息
   */
  public RCException(Integer resultCode, String message) {
    super(message);
    this.resultCode = new ResultCode(resultCode, message);
  }


  /**
   * 异常ResultCode
   */
  public RCException(ResultCode resultCode) {
    super(resultCode.getMessage());
    this.resultCode = resultCode;
  }

  public RCException(ResultCode resultCode, Throwable cause) {
    super(resultCode.getMessage(), cause);
    this.resultCode = resultCode;
  }

  public RCException(Integer resultCode, String message, Throwable cause) {
    super(message, cause);
    this.resultCode = new ResultCode(resultCode, message);
  }

  public RCException(String message, Throwable cause) {
    super(message, cause);
    this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
  }

}
